Use Max rate to charge for Notice Period#95
Merged
roshanrags merged 4 commits intoarbitrumfrom Mar 16, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances smart contract functionality and its associated tests by introducing a new field (maxRate) in the MarketV1 contract to accurately track rate changes, updates event definitions to include timestamp data, and improves deposit/withdrawal as well as emergency procedures. Key changes include:
- Updates in MarketV1.sol to remove the extra settleTill parameter and compute settlement using block.timestamp, while integrating maxRate for rate revisions.
- Enhancements in Credit.sol with pause/unpause capabilities and refined redeemAndBurn functionality.
- Adjustments in tests and deployment scripts to align with the new contract logic and behavior.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/token/Credit.ts | Added comprehensive tests for access control, mint/burn, redeemAndBurn, and pause/unpause behavior. |
| test/enclaves/MarketV1.ts | Updated test assertions for job settlement and deposit/withdraw logic using block.timestamp values. |
| scripts/deploy/enclaves/UpgradeMarketV1.ts | Comments out deprecated reinitialization logic post-upgrade. |
| contracts/token/Credit.sol | Introduced PAUSER_ROLE and updated function documentation; adjusted redeemAndBurn sequence. |
| contracts/enclaves/MarketV1.sol | Redesigned job settlement and rate revision logic using block.timestamp and introduced maxRate. |
| addresses/421614.json | Updated MarketV1 implementation address. |
Comments suppressed due to low confidence (1)
contracts/token/Credit.sol:141
- Verify that burning tokens before transferring USDC is the intended sequence; ensure that if the USDC transfer fails after burning, the contract state remains consistent or appropriate error handling is in place.
function redeemAndBurn(address _to, uint256 _amount) external whenNotPaused onlyRole(REDEEMER_ROLE) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several updates to the
MarketV1smart contract, theCredittoken contract, and associated deployment scripts and tests. The changes focus on improving functionality, enhancing security, and aligning the implementation with updated requirements. Key updates include modifications to job settlement logic, the addition of new features in theCreditcontract, and updates to tests to reflect these changes.Updates to
MarketV1Contract:maxRatefield to theJobstruct to track the highest rate for a job. This field is updated when a new higher rate is set, and additional logic ensures sufficient balance to cover the notice period's extra cost. (contracts/enclaves/MarketV1.sol, [1] [2]JobOpenedandJobClosedto include atimestampfield, improving traceability. (contracts/enclaves/MarketV1.sol, [1] [2]_jobSettlefunction by removing thesettleTillparameter and usingblock.timestampdirectly. This change also ensures the job balance and rate are validated before settlement. (contracts/enclaves/MarketV1.sol, contracts/enclaves/MarketV1.solL287-R311)_emergencyWithdrawCreditto directly update the job balance and emit aJobWithdrawnevent, ensuring better transparency during emergency withdrawals. (contracts/enclaves/MarketV1.sol, contracts/enclaves/MarketV1.solL253-R263)Updates to
CreditContract:pauseandunpausefunctions with a newPAUSER_ROLE, allowing the contract to be paused for security or administrative reasons. (contracts/token/Credit.sol, contracts/token/Credit.solR133-R169)mint,burn, andredeemAndBurn, improving code clarity. (contracts/token/Credit.sol, [1] [2]USDCaddress public for better visibility. (contracts/token/Credit.sol, contracts/token/Credit.solL78-R83)Deployment and Testing Updates:
UpgradeMarketV1.tsdeployment script, as it is no longer required. (scripts/deploy/enclaves/UpgradeMarketV1.ts, scripts/deploy/enclaves/UpgradeMarketV1.tsL39-R42)MarketV1to validate the newmaxRatefield and ensurelastSettledtimestamps match the block timestamp when a job is opened. (test/enclaves/MarketV1.ts, [1] [2]These changes collectively enhance the robustness, clarity, and maintainability of the contracts and associated codebase.